<?php
namespace App\Model\front;

use Illuminate\Database\Eloquent\Model;
use DB;

class UserModel extends Model{
    const USER = 'user';

    //用户注册信息添加
    public function addUserInfo($data)
    {
        return DB::table(self::USER)->insertGetId($data);
    }

    //邮箱验证激活
    public function activeEmail($where = [])
    {
    	$res = DB::table(self::USER)->where($where)->select('username','user_id')->first();
    	if ($res) {
    		if(DB::table(self::USER)->where('user_id',$where['user_id'])->update(['status'=>'1'])) return true;
    		return false;
    	}
    }

    //根据email获取用户数据
    public function getInfoByEmail($where)
    {
    	return DB::table(self::USER)->where($where)->select('user_id','username','password','status','email')->first();

    }
}